package com.whyx.project.openapi.map;

import exsun.jt808.data.enume.OrderHttpStatus;
import exsun.jt808.data.enume.OrderSendStatus;

import java.util.HashMap;
import java.util.Map;

public class OrderSendStatus2HttpStatus {
    private static Map<OrderSendStatus, OrderHttpStatus> map = new HashMap();
    static {
        map.put(OrderSendStatus.待下发, OrderHttpStatus.待下发);//0
        map.put(OrderSendStatus.发送成功, OrderHttpStatus.发送成功);//1
        map.put(OrderSendStatus.消息处理异常, OrderHttpStatus.发送失败);//2
        map.put(OrderSendStatus.指令参数有误, OrderHttpStatus.发送失败);//2
        map.put(OrderSendStatus.设备通用应答成功, OrderHttpStatus.通用应答成功);//3
        map.put(OrderSendStatus.设备特殊应答成功, OrderHttpStatus.特殊应答成功);//4
        map.put(OrderSendStatus.设备不在线, OrderHttpStatus.配置失败);//5
        map.put(OrderSendStatus.设备应答超时, OrderHttpStatus.配置失败);//5
        map.put(OrderSendStatus.设备应答失败, OrderHttpStatus.配置失败);//5
    }

    public OrderHttpStatus getOrderSendStatus(int code){
        for (OrderSendStatus key:map.keySet()) {
            if(key.ordinal() == code)
                return map.get(key);

        }
        return null;
    }

    public Integer getOrderSendStatusCode(int code){
        OrderHttpStatus temp = getOrderSendStatus(code);
        if(temp == null)return null;
        return temp.ordinal();
    }

    public String getOrderSendStatusMsg(int code){
        OrderHttpStatus temp = getOrderSendStatus(code);
        if(temp == null)return null;
        return temp.name();
    }

    public String getOrderHttpStatusMsg(int code){
        for (OrderSendStatus key:map.keySet()) {
            if(key.ordinal() == code)
                return key.name();
        }
        return null;
    }
}
